home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Purity / Purity #34 (1994-08)(Diesel)(DE)[WB].zip / Purity #34 (1994-08)(Diesel)(DE)[WB].adf / IncludesPCQ / DOSAsl.i < prev    next >
Text File  |  1994-08-06  |  5KB  |  152 lines

  1.  
  2. {$I   "Include:Exec/Libraries.i"}
  3. {$I   "Include:Exec/Lists.i"}
  4. {$I   "Include:DOS/DOS.i"}
  5.  
  6.  
  7. {**********************************************************************
  8. ************************ PATTERN MATCHING ******************************
  9. ************************************************************************
  10.  
  11. * structure expected by MatchFirst, MatchNext.
  12. * Allocate this structure and initialize it as follows:
  13. *
  14. * Set ap_BreakBits to the signal bits (CDEF) that you want to take a
  15. * break on, or NULL, if you don't want to convenience the user.
  16. *
  17. * If you want to have the FULL PATH NAME of the files you found,
  18. * allocate a buffer at the END of this structure, and put the size of
  19. * it into ap_Strlen.  If you don't want the full path name, make sure
  20. * you set ap_Strlen to zero.  In this case, the name of the file, and stats
  21. * are available in the ap_Info, as per usual.
  22. *
  23. * Then call MatchFirst() and then afterwards, MatchNext() with this structure.
  24. * You should check the return value each time (see below) and take the
  25. * appropriate action, ultimately calling MatchEnd() when there are
  26. * no more files and you are done.  You can tell when you are done by
  27. * checking for the normal AmigaDOS return code ERROR_NO_MORE_ENTRIES.
  28. *
  29. }
  30.  
  31. Type
  32.        AChain = Record
  33.         an_Child,
  34.         an_Parent   : ^AChain;
  35.         an_Lock     : BPTR;
  36.         an_Info     : FileInfoBlock;
  37.         an_Flags    : Byte;
  38.         an_String   : Array[0..0] of Char;   { FIX!! }
  39.        END;
  40.        AChainPtr = ^AChain;
  41.  
  42.  
  43.        AnchorPath = Record
  44.         ap_Base,                    { pointer to first anchor }
  45.         ap_Last  : AChainPtr;       { pointer to last anchor }
  46.         ap_BreakBits,               { Bits we want to break on }
  47.         ap_FoundBreak : Integer;    { Bits we broke on. Also returns ERROR_BREAK }
  48.         ap_Flags      : Byte;       { New use for extra word. }
  49.         ap_Reserved   : Byte;
  50.         ap_Strlen     : Short;      { This is what ap_Length used to be }
  51.         ap_Info       : FileInfoBlock;
  52.         ap_Buf        : Array[0..0] of Char;     { Buffer for path name, allocated by user !! }
  53.         { FIX! }
  54.        END;
  55.        AnchorPathPtr = ^AnchorPath;
  56.  
  57.  
  58. CONST
  59.     APB_DOWILD    =  0;       { User option ALL }
  60.     APF_DOWILD    =  1;
  61.  
  62.     APB_ITSWILD   =  1;       { Set by MatchFirst, used by MatchNext  }
  63.     APF_ITSWILD   =  2;       { Application can test APB_ITSWILD, too }
  64.                                 { (means that there's a wildcard        }
  65.                                 { in the pattern after calling          }
  66.                                 { MatchFirst).                          }
  67.  
  68.     APB_DODIR     =  2;       { Bit is SET IF a DIR node should be }
  69.     APF_DODIR     =  4;       { entered. Application can RESET this }
  70.                                 { bit after MatchFirst/MatchNext to AVOID }
  71.                                 { entering a dir. }
  72.  
  73.     APB_DIDDIR    =  3;       { Bit is SET for an "expired" dir node. }
  74.     APF_DIDDIR    =  8;
  75.  
  76.     APB_NOMEMERR  =  4;       { Set on memory error }
  77.     APF_NOMEMERR  =  16;
  78.  
  79.     APB_DODOT     =  5;       { IF set, allow conversion of '.' to }
  80.     APF_DODOT     =  32;      { CurrentDir }
  81.  
  82.     APB_DirChanged  = 6;       { ap_Current->an_Lock changed }
  83.     APF_DirChanged  = 64;      { since last MatchNext call }
  84.  
  85.  
  86.     DDB_PatternBit  = 0;
  87.     DDF_PatternBit  = 1;
  88.     DDB_ExaminedBit = 1;
  89.     DDF_ExaminedBit = 2;
  90.     DDB_Completed   = 2;
  91.     DDF_Completed   = 4;
  92.     DDB_AllBit      = 3;
  93.     DDF_AllBit      = 8;
  94.     DDB_Single      = 4;
  95.     DDF_Single      = 16;
  96.  
  97. {
  98.  * Constants used by wildcard routines, these are the pre-parsed tokens
  99.  * referred to by pattern match.  It is not necessary for you to do
  100.  * anything about these, MatchFirst() MatchNext() handle all these for you.
  101.  }
  102.  
  103.     P_ANY         =  $80;    { Token for '*' or '#?  }
  104.     P_SINGLE      =  $81;    { Token for '?' }
  105.     P_ORSTART     =  $82;    { Token for '(' }
  106.     P_ORNEXT      =  $83;    { Token for '|' }
  107.     P_OREND       =  $84;    { Token for ')' }
  108.     P_NOT         =  $85;    { Token for '~' }
  109.     P_NOTEND      =  $86;    { Token for }
  110.     P_NOTCLASS    =  $87;    { Token for '^' }
  111.     P_CLASS       =  $88;    { Token for '[]' }
  112.     P_REPBEG      =  $89;    { Token for '[' }
  113.     P_REPEND      =  $8A;    { Token for ']' }
  114.     P_STOP        =  $8B;    { token to force end of evaluation }
  115.  
  116. { Values for an_Status, NOTE: These are the actual bit numbers }
  117.  
  118.     COMPLEX_BIT   =  1;       { Parsing complex pattern }
  119.     EXAMINE_BIT   =  2;       { Searching directory }
  120.  
  121. {
  122.  * Returns from MatchFirst(), MatchNext()
  123.  * You can also get dos error returns, such as ERROR_NO_MORE_ENTRIES,
  124.  * these are in the dos.h file.
  125.  }
  126.  
  127.     ERROR_BUFFER_OVERFLOW  = 303;     { User OR internal buffer overflow }
  128.     ERROR_BREAK            = 304;     { A break character was received }
  129.     ERROR_NOT_EXECUTABLE   = 305;     { A file has E bit cleared }
  130.  
  131. PROCEDURE MatchEnd(A : AnchorPathPtr);
  132.     External;
  133.  
  134. FUNCTION MatchFirst(pattern : String; A : AnchorPathPtr) : Integer;
  135.     External;
  136.  
  137. FUNCTION MatchNext(A : AnchorPathPtr) : Integer;
  138.     External;
  139.  
  140. FUNCTION MatchPattern(pattern : Address; Str : String) : Boolean;
  141.     External;
  142.  
  143. FUNCTION MatchPatternNoCase(pattern : Address; Str : String) : Boolean;
  144.     External;
  145.  
  146. FUNCTION ParsePattern(pattern, Buffer : String; BufferSize : Integer) : Integer;
  147.     External;
  148.  
  149. FUNCTION ParsePatternNoCase(pattern, Buffer : String; BufferSize : Integer) : Integer;
  150.     External;
  151.  
  152.